package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.common.result.Result;
import com.atguigu.srb.core.pojo.entity.Lend;
import com.atguigu.srb.core.service.LendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.LICENSE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author lsyandwh
 * @since 2022-12-02
 */
@Api(tags = "标的管理")
@RestController
@RequestMapping("/admin/core/lend")
public class AdminLendController {

    @Autowired
    private LendService lendService;

    @ApiOperation("放款")
    @GetMapping("/makeLoan/{id}")
    public Result makeLoan(@PathVariable Long id){

        lendService.makeLoan(id);

        return Result.ok();
    }

    @ApiOperation("标的列表")
    @GetMapping("/list")
    public Result lendList(){

        List<Lend> list = lendService.lendList();

        return Result.ok().data("list",list);
    }

    @ApiOperation("标的详情")
    @GetMapping("/show/{id}")
    public Result show(@PathVariable Long id){
        Map<String,Object> map = lendService.show(id);

        return Result.ok().data("lendDetail",map);
    }

}

